/*--------------------------*/
/*
This generates the values needed for Table 1
in MacKinnon and Webb (2017) TPM

This program uses the boottest package
https://ideas.repec.org/c/boc/bocode/s458121.html

This can be installed by typing
ssc install boottest

*/
/*--------------------------*/

set seed 42

clear all
set more off

version 14

/*set directory*/

*cd "C:\Users\me\"

*** uses BCMM_replication.dta" ***

use "BCMM_replication.dta", clear

/*control variables*/
global xcovs "perblack12 perhisp12 medianincome bachelorsplus per6512 pop populationdensity"

/*generate new treatment variables*/

	/*adopted early  voting*/
	gen adopt = (early2008  ==0 & early2012 ==1)
	
	/*repealed early  voting*/
	gen repeal = (early2008  ==1 & early2012 ==0)
	
	/*adopted early(+1) repealed early voting(-1)*/
	gen fixed_symm = adopt - repeal 

********* column one **********
/*BCMM treatment variable*/

 /*robust standard error*/
regress demdiff_2012to2008 early_diff_2012to2008 exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], vce(robust)

/*cluster by ctyfips*/
regress demdiff_2012to2008 early_diff_2012to2008 exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(ctyfips)

/*cluster by state*/
regress demdiff_2012to2008 early_diff_2012to2008 exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(state) 

/*WCU*/
boottest early_diff_2012to2008, boottype(wild) nonull cluster(state) seed(96) reps(99999) nograph

/*WCR*/
boottest early_diff_2012to2008, boottype(wild) cluster(state) seed(96) reps(99999) nograph


********* column two *********
/*fixed symmetric treatment variable*/

/*robust standard error*/
regress demdiff_2012to2008 fixed_symm exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], vce(robust)

/*cluster by ctyfips*/
regress demdiff_2012to2008 fixed_symm exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(ctyfips)

/*cluster by state*/
regress demdiff_2012to2008 fixed_symm exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(state) 

/*WCU*/
boottest fixed_symm, boottype(wild) cluster(state) nonull seed(96) reps(99999) nograph

/*WCR*/
boottest fixed_symm, boottype(wild) cluster(state) seed(96) reps(99999) nograph

********** column three and four ********
/*column 3 - adopted*/
/*column 4 - repeal*/
/*robust standard error*/
regress demdiff_2012to2008 adopt repeal exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], vce(robust)

/*cluster by ctyfips*/
regress demdiff_2012to2008 adopt repeal exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(ctyfips)
 
/*cluster by state*/
regress demdiff_2012to2008 adopt repeal exfelon_diff_2012to2008 id_diff_2012to2008 $xcovs ///
[aweight=popestres], cluster(state)

/*column 3 - bootstraps*/

/*WCU*/
boottest adopt, boottype(wild) cluster(state) nonull seed(96) reps(99999) nograph

/*WCR*/
boottest adopt, boottype(wild) cluster(state) seed(96) reps(99999) nograph

/*column 4 - bootstraps*/

/*WCU*/
boottest repeal, boottype(wild) cluster(state) nonull seed(96) reps(99999) nograph


/*WCR*/
boottest repeal, boottype(wild) cluster(state) seed(96) reps(99999) nograph







	
